<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="/misc/css/base.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/btnicon.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/reset_admin.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/adminmenu.css"  />
<link rel="stylesheet" type="text/css" href="/misc/css/newadmin.css"  />
<script type="text/javascript" src="/misc/vendors/jquery/jquery_1.2.6.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js.js"></script>
<script type="text/javascript" src="/misc/vendors/o2js/o2js_build.js"></script>
<script type="text/javascript" >
var baseUrl = "<?=$themeUrl?>";
$().ready(function(){

});
var grids;
</script>
</head>
<style type="text/css">
/* 主面板 */
table.tdashboard{
width:100%;
border-collapse:collapse;
margin:0px;
padding:0px;
background-color:#fefefe;
}
table.tdashboard td.tdashboardl{
text-align:left;
vertical-align:top;
padding:10px;
width:180px;
}
table.tdashboard td.tdashboardr{
text-align:left;
vertical-align:top;
padding:10px;
}

a.cancel:link, a.cancel:visited {
color: #FF0000;
font-size: 12px;
font-weight: normal;
}
a.cancel:hover{
background-color:#FF0000;
color:#FFFFFF;
}

/* 通用表格 */
table.tablestand{
border: 1px solid #C7CDD4;
border-collapse: collapse;
width: 100%;
}
table.tablestand thead td.tdtitle{
background: url("/misc/images/billtb_thbg.gif") repeat-x scroll center bottom #FFFFFF;
color: #185A80;
font-size: 12px;
font-weight: bold;
text-align:center; 
padding:7px; 
background-color:#FFFFFF;
border:1px solid #C7CDD4;
}
table.tablestand tbody td.tdvalue{
background-color: #FFFFFF;
border: 1px solid #C7CDD4;
padding: 7px;
text-align: left;
text-align:center;
}
table.tablestand td.tdleft{
text-align:left !important;
}
table.tablestand td.tdright{
text-align:right !important;
}
table.tablestand td.tdcenter{
text-align:center !important;
}

</style>
<body   style="background-color:#fcfcfc;">
<table class="tdashboard">
	<tr> 
		<td class="tdashboardr">
		<div class="margin10" style="color:gray">
			溯源阶段：<span style="color:green;font-size:1.5em"><?=$rs_who['name']?></span>
		</div>
		<div style="margin: 10px auto; line-height:20px;">
			<div style="float:left;">
				<a href="javascript:void(0)" onclick="fnAddField()"><input type="button" class="btnicon_add" /> 添加自定义属性</a>
				 
			</div> 
		</div>
		<div style="clear:both;"></div>
		<table class="tablestand">
			<thead>
				<tr>
					<td class="tdtitle tdleft">属性名称</td>
					<td class="tdtitle">属性类型</td>
					<td class="tdtitle tdright">操作</td>
				</tr>
			</thead>
			<tbody>
					<?PHP
					foreach($rs as $v){
					    //显示对应的中文说明
					    $_field_type = '';
					    foreach ($field_type as $kk=>$vv):
					        if ($vv['type'] == $v['field_type']):
					            $_field_type = $vv['text'];
					            break;
					        endif;
					    endforeach;
						echo '
					<tr id="tr_'.$v['id'].'">
						<td class="tdvalue tdleft"> '.$v['field_name'].' </td>
						<td class="tdvalue"> '.$_field_type.' </td>
						<td class="tdvalue tdright">
							<input type="hidden" value="'.$v['id'].'" id="id_'.$v['id'].'" class="optid" />
							<a href="javascript:void(0)" onclick="fnMoveTop('.$v['id'].')" title="上移排序">↑</a>
							<a href="javascript:void(0)" onclick="fnMoveBottom('.$v['id'].')" title="下移排序">↓</a>
							<a href="javascript:void(0)" onclick="fnModify('.$v['id'].')">[修改]</a>
							<a href="javascript:void(0)" onclick="fnDelete('.$v['id'].')" class="cancel">[删除]</a>
						</td>
					</tr>
						';
					}
					?> 
				</tbody>
		</table>
		</td>
	</tr>
</table>
<script type="text/javascript">  
var rs_who = <?=json_encode($rs_who)?>;
var url_delete = "/admin_field/del"; 
var url_showindex = "/admin_field/modify_field_showindex";
var url_add = "/admin_field/add"; 
var url_modify_field = '/admin_field/modify_field';

var rs = <?=json_encode($rs)?>;
$().ready(function(){
	o2js.build('ymprompt');
});
function fnAddField()
{
	ymPrompt.close();
	ymPrompt.win({
		title:'添加自定义属性',
		fixPosition:true,
		maxBtn:true,
		width: 700,
		height: 400,
		iframe:{
			src:url_add+'?id='+rs_who.id
		}
	});
	
}
/* 删除 */
function fnDelete(id){
	fnConfirm({
		str:'确定删除吗？',
		func_true:function(){
			fnLoading();
			$.post(
				url_delete,
				{
					id:id
				},
				function(e){
					fnLoadingEnd();
					var ok = errorHandler(e);
					if(ok && ok.success=='1'){ 
						window.location.reload();
					}
				}
			);
		}
	});
}
/* 修改字段属性 */
function fnModify(id){
	ymPrompt.close();
	ymPrompt.win({
		title:'修改自定义属性',
		fixPosition:true,
		maxBtn:true,
		width: 700,
		height: 400,
		iframe:{
			src:url_modify_field+'?id='+id
		}
	});
}  
/* 排上去 */
function fnMoveTop(i){ 
	var nowdiv = $('#tr_'+i); 
	var updiv = nowdiv.prev(); 
	if(updiv) updiv.before(nowdiv); 
	__fnGroupPaixu();
}
/* 排下去 */
function fnMoveBottom(i){
	var nowdiv = $('#tr_'+i);
	var downdiv = nowdiv.next(); 
	if(downdiv) downdiv.after(nowdiv); 
	__fnGroupPaixu();
}
/* 排完以后分组排序 */
function __fnGroupPaixu(){
	var groupindex = [];
	var i=1;
	$('.optid').each(function(){
		groupindex.push({
			id:$(this).val(),
			show_index:i++
		});
	}); 
	$.post(
		url_showindex,
		{
			groupindex:JSON.encode(groupindex)
		},
		function(e){
		  var ok = errorHandler(e);
		}
	);
}
</script>
</body>
</html>